// 导入用户集合
const { Guestbook } = require('../../../model/guestbook');

module.exports = async (req, res) => {
	const { content } = req.body
	if (!content) {
		res.status(403)
		res.json({
		    message: '留言不能为空！'
		})
	}
  Guestbook.create(req.body).then(async item => {
	const current = await Guestbook.findOne({_id: item._id}).populate('user', 'nickname avatar username')
    res.json({
        data: current,
        message: '留言成功！'
    })
  }).catch((err) => {
    res.status(403)
    res.json({
        log: err,
        message: '留言失败！'
    })
  })
}